package edu.umb.cs.antmanager.common;

import java.rmi.Remote;
import java.rmi.RemoteException;
import com.healthmarketscience.rmiio.RemoteInputStream;
import edu.umb.cs.antmanager.domain.TestType;

/**
 * Agent's Remote Interface, defines methods that manager can call remotely.
 * 
 * @author 2009CS682-3UMB_AntManager
 * 
 */
public interface AgentInterface extends Remote {

	/**
	 * Get the agent's status
	 * 
	 * @return <tt>MachineStatus</tt> which contains the agent's status info
	 * @throws RemoteException
	 */
	public MachineStatus getStatus() throws RemoteException;

	/**
	 * Run a test on the agent
	 * 
	 * @param test
	 *            <tt>TestType</tt> which contains the info of a test
	 * @param managerStub
	 *            manager's host name, needed for agent to send back result
	 * @return true, if test was executed; false, if the agent refuse to execute
	 *         the task
	 * @throws RemoteException
	 */
	public boolean executeTask(TestType test, ManagerInterface managerStub)
			throws RemoteException;

	/**
	 * Run ant command just like what you did in a console.
	 * 
	 * @param cmd
	 *            String contains the command which will pass to Ant
	 * @return <tt>RemoteInputSream</tt> for reading the execution result
	 * @throws RemoteException
	 */
	public RemoteInputStream executeCommand(String cmd) throws RemoteException;

	public RemoteInputStream getRunningLog() throws RemoteException;

	/**
	 * Shutdown the agent
	 * 
	 * @throws RemoteException
	 */
	public void shutDown() throws RemoteException;

	/**
	 * Restart the agent
	 * 
	 * @throws RemoteException
	 */
	public void restart() throws RemoteException;
}
